package cn.bob.org.eum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;
// 日志所需要的枚举类
@AllArgsConstructor
@Getter
public enum  DeptEum {
    addOrUpdate("addOrUpdate", "新增或者修改"),
    delete("delete", "根据id删除"),
    queryByPage("queryByPage", "查询分页列表");
    private String code;
    private String des;
    // 判断方法是否在 集合中
    public static Boolean isExist(String code) {
        Optional<DeptEum> any = Arrays.stream(DeptEum.values()).filter(e -> code.equalsIgnoreCase(e.getCode())).findAny();
        return any.isPresent();
    }
    // 根据code 获取 描述
    public static String getDesByCode(String code) {
        DeptEum deptEum = Arrays.stream(DeptEum.values()).filter(e -> code.equalsIgnoreCase(e.getCode())).findAny().orElse(null);
        return null==deptEum ?"":deptEum.getDes();
    }
}
